{*  SEO Backlink helper *}
<div style="display: none;">
 {foreach from=$langs item=lang}
    <a href="/{$lang.url_prefix}" title="{$lang.name}" alt="{$lang.name}">{$lang.name}</a>
 {/foreach}
</div>
{* End seo backlink *}

<script type="text/javascript">
 var _absoft_available_language = new Array();
    {foreach from=$langs item=lang}
        _absoft_available_language.push("{$lang.lang_code}");
    {/foreach}
    var _ab_current_url = "{$current_path}";
    if(self != top) {ldelim}
         top.location.href = top.c.location.href; 
    {rdelim}
    
    function google_translate(value)
    {ldelim}
        if (value == "")
            return;
            
        // before use google translate, remember to check our available language
        for (var i = 0; i< _absoft_available_language.length; i++)    
        {ldelim}
            if (_absoft_available_language[i] == value)
            {ldelim}
                window.location = '{$smarty.const.URL_FULL}index.php?module=langmodule&action=changelang&lid='+value;
                return;
            {rdelim}
        {rdelim}
        // else, -> google tranlsate
        glink = "http://translate.google.com/translate?hl=en&sl=auto&tl="+value+"&u="+_ab_current_url;
        
        document.location = glink;
    {rdelim}
    
    jQuery(document).ready(function() {ldelim}
            
            if(self != top) {ldelim} top.location.href = top.c.location.href; {rdelim} 
       
            if (document.location.host == "translate.googleusercontent.com")
            {ldelim}
                // we are in google translate mode
                var tl_pos = document.location.href.search("tl=");
                var tl_lang = document.location.href.substr(tl_pos + 3, 2);
                //jQuery("#old_sl").val(tl_lang);
                //jQuery("#polyglotLanguageSwitcher > .dropdown li a[id='"+tl_lang+"']").trigger("click");
                jQuery("#polyglot-language-options option").attr("selected","");
                jQuery("#polyglot-language-options option[value='"+tl_lang+"']").attr("selected", "selected");
            {rdelim}
            
             jQuery('#polyglot-language-options').bind("change",function () {ldelim}
                    google_translate(this.value);
               {rdelim});
    {rdelim});
</script>
 
<div id="polyglotLanguageSwitcher" class="notranslate">
        <select id="polyglot-language-options" {if $userlogin==1}class="polyglot-language-options_had_login"{/if}>
            {foreach from=$langs item=lang}
                <option {if $smarty.const.LANG_LOCALE == $lang.locale}selected{/if} id="{$lang.lang_code}" value="{$lang.lang_code}" >{$lang.name}</option>
            {/foreach}
            {if $google_translate}
            <option value="">-----------------</option>
            <option value="">Google Translate</option>
            <option id="af" value="af">Afrikaans</option>
            <option value="sq" id="sq">Albanian</option>
            <option id="ar" value="ar">Arabic</option>
            <option value="be" id="be">Belarusian</option>
            <option id="bg" value="bg">Bulgarian</option>
            <option id="ca" value="ca">Catalan</option>
            <option id="cn" value="zh-CN">Chinese</option>
            <option id="hr" value="hr">Croatian</option>
            <option id="cs" value="cs">Czech</option>
            <option id="da" value="da">Danish</option>
            <option id="nl" value="nl">Dutch</option>
            <option id="et" value="et">Estonian</option>
            <option id="tl" value="tl">Filipino</option>
            <option id="fi" value="fi">Finnish</option>
            <option id="fr" value="fr">French</option>
            <option id="gl" value="gl">Galician</option>
            <option id="el" value="el">Greek</option>
            <option id="ht" value="ht">Haitian Creole ALPHA</option>
            <option id="iw" value="iw">Hebrew</option>
            <option id="hi" value="hi">Hindi</option>
            <option id="hu" value="hu">Hungarian</option>
            <option id="is" value="is">Icelandic</option>
            <option id="id" value="id">Indonesian</option>
            <option id="ga" value="ga">Irish</option>
            <option id="ja" value="ja">Japanese</option>
            <option id="ko" value="ko">Korean</option>
            <option id="lv" value="lv">Latvian</option>
            <option id="lt" value="lt">Lithuanian</option>
            <option id="mk" value="mk">Macedonian</option>
            <option id="ms" value="ms">Malay</option>
            <option id="mt" value="mt">Maltese</option>
            <option id="no" value="no">Norwegian</option>
            <option id="fa" value="fa">Persian</option>
            <option id="pl" value="pl">Polish</option>
            <option id="pt" value="pt">Portuguese</option>
            <option id="ro" value="ro">Romanian</option>
            <option id="sr" value="sr">Serbian</option>
            <option id="sk" value="sk">Slovak</option>
            <option id="sl" value="sl">Slovenian</option>
            <option id="es" value="es">Spanish</option>
            <option id="sv" value="sv">Swedish</option>
            <option id="th" value="th">Thai</option>
            <option id="uk"value="uk">Ukrainian</option>
            <option id="vi" value="vi">Vietnamese</option>
            <option id="cy" value="cy">Welsh</option>
            {/if}
        </select>
</div>